#include "State_Intro.h"
//#include "MainMenuState.h"

IntroState::IntroState(sf::RenderWindow &windowIn, StateManager& stateManagerIn) :
GameState(windowIn, stateManagerIn), bgFilename("img/bg/introBG.png"), bgTexture(txtrMgr.get(bgFilename)), opacity(0)
{
	bgSprite.setTexture(bgTexture);
}

IntroState::~IntroState()	//IntroState has no need for these, but the other GameStates do
{
	clog << "Destroying IntroState.\n";
}

void IntroState::init()		//IntroState has no need for these, but the other GameStates do
{
}

void IntroState::exit()		//IntroState has no need for these, but the other GameStates do
{
}

void IntroState::pause()	//IntroState has no need for these, but the other GameStates do
{
}

void IntroState::resume()	//IntroState has no need for these, but the other GameStates do
{
}

void IntroState::getInput(sf::RenderWindow& window)
{
	sf::Event evt;
	if (window.pollEvent(evt))
	{
		switch (evt.type)
		{
		case sf::Event::Closed:
			window.close();
			break;
		case sf::Event::MouseButtonPressed:
		case sf::Event::KeyPressed:
			opacity = 255;
			break;
		default:
			break;
		}
	}

}

void IntroState::update(StateManager& stateManager)
{
	if (opacity >= 250)
	{
		stateManager.quit();

	}
	opacity += 5;
	bgSprite.setColor(sf::Color(255, 255, 255, opacity));
}

void IntroState::draw(sf::RenderWindow& window)
{
	window.clear(sf::Color(255, 255, 255));
	window.draw(bgSprite);
	window.display();
}